using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NTTHAO.CommonWeb;
using NTTHAO.Web.BL.CommonPage;

public partial class admin_webparts_Common_SiteSwitch : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        btnChange.Text = LanguageUtility.GetLanguageText("CHANGE", Session);

        if (!IsPostBack)
        {
            try
            {
                //NTTHAO.Web.BL.CommonPage.CommonSite site = new NTTHAO.Web.BL.CommonPage.CommonSite();
                DataSet ds = CommonSite.GetAll();
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    cmbSite.DataSource = ds.Tables[0];
                    cmbSite.DataTextField = CommonSite.SITENAME__COLUMN_NAME;
                    cmbSite.DataValueField = CommonSite.ID__COLUMN_NAME;

                    CommonSite site = CommonSite.GetDefaultSite();
                    if (site != null)
                    {
                        cmbSite.SelectedValue = site.ID.ToString();
                    }
                    cmbSite.DataBind();
                }
            }
            catch (Exception) { }
        }
    }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        try
        {
            int siteID = Int32.Parse(cmbSite.SelectedValue);
            CommonSite site = new CommonSite(siteID);
            if (site.ID > 0)
            {
                CommonSite.SetDefaultSite(siteID);
            }
        }
        catch { }
        Response.Redirect("?", false);
    }
}
